//
//  LocationMapViewController.m
//  KKZ
//
//  Created by Bismarrck on 11-7-21.
//  Copyright 2011年 Tsinghua University. All rights reserved.
//

#import "LocationMapViewController.h"
#import "UIViewController+BarItem.h"
#import "UserDefault.h"

@implementation LocationMapViewController

@synthesize locationMap;
@synthesize map;
@synthesize infoLabel;
@synthesize commCircleName;

- (id)initWithCommCircleMap:(UIImage *)mapImage name:(NSString *)circleName;
{
    self = [super init];
    if (self) {
        self.map = mapImage;
        self.commCircleName = circleName;
    }
    
    return self;
}


- (void)dealloc
{
    [locationMap release];
    [infoLabel release];
    [map release];
    [commCircleName release];
    
    cityName_ = nil;
    districtName_ = nil;
    
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    // Load the city and district info
    cityName_ = USER_DEFAULT_CITY;
    districtName_ = USER_DEFAULT_DISTRICT;
    
    // Set the comm circle map
    self.locationMap.image = self.map;
    
    // Set the title
    [self addTitleToNavigationBar:@"商圈地图"];
    
    // Set the info label
    [self.infoLabel setText:[NSString stringWithFormat:@"%@>%@>%@", cityName_, districtName_, self.commCircleName]];
    
    // Set the background image
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background_light.png"]];
    
    // Set the back barItem
    [self createBarItemOn:kNavBarItemSideLeft frame:kNavBarLeftItemFrame title:@"返回" target:self action:@selector(popBackToLastViewController)];
    
}

- (void)viewDidUnload
{
    [super viewDidUnload];

    self.locationMap = nil;
    self.infoLabel = nil;
    self.map = nil;
    self.commCircleName = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
